<html>
<head><meta charset="utf-8"><title>pattern of remapping indices during deserialization · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html">pattern of remapping indices during deserialization</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204251191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204251191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204251191">(Jul 17 2020 at 19:56)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="119009">@eddyb</span> (or anyone else who may know), while reviewing PR <a href="https://github.com/rust-lang/rust/issues/72121">#72121</a>, I am sitting here wondering "I feel like I've seen this pattern elsewhere in the rustc source, of dynamically picking a new ID in the current space and tracking an on-disk-id-&gt;in-memory-id map in some fashion</p>



<a name="204251462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204251462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204251462">(Jul 17 2020 at 19:59)</a>:</h4>
<p>but my brief attempts to skim the metadata code have left me shrugging my shoulders.</p>



<a name="204251774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204251774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204251774">(Jul 17 2020 at 20:02)</a>:</h4>
<p>(the closest thing I've found so far isn't really quite the same thing; the <code>rustc_span::source_map</code> code does need to keep track of how the <code>start_pos</code> and <code>end_pos</code> need to be adjusted as we load in new files)</p>



<a name="204251855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204251855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204251855">(Jul 17 2020 at 20:02)</a>:</h4>
<p>Really I was just sitting here wondering "is this a common pattern that we should be putting into its own crate for rustc?"</p>



<a name="204279185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204279185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204279185">(Jul 18 2020 at 02:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> remapping <code>CrateNum</code> is the main one I know of</p>



<a name="204279230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204279230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204279230">(Jul 18 2020 at 02:24)</a>:</h4>
<p>I don't think it's "common" in the sense of showing up many times, enough to warrant an abstraction</p>



<a name="204315929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204315929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204315929">(Jul 18 2020 at 20:14)</a>:</h4>
<p>Oh yes, CrateNum is probably what I was thinking of.</p>



<a name="204315950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/pattern%20of%20remapping%20indices%20during%20deserialization/near/204315950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/pattern.20of.20remapping.20indices.20during.20deserialization.html#204315950">(Jul 18 2020 at 20:16)</a>:</h4>
<p>And you are probably right that trying to develop an abstraction for this is not worth it. But I would like to maybe review both in parallel; it’s possible past lessons from one could apply to the newer one</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>